package com.thor.palmmall.rest.inspect.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.common.SAttachment2Converter;
import com.thor.palmmall.rest.inspect.AInspectBill;
import com.thor.palmmall.spi.inspect.SInspectBill;

public class SInspectBillConverter implements Converter<AInspectBill, SInspectBill> {

  private static SInspectBillConverter instance;

  public static SInspectBillConverter getInstance() {
    if (instance == null)
      instance = new SInspectBillConverter();
    return instance;
  }

  @Override
  public SInspectBill convert(AInspectBill source) {
    if (source == null)
      return null;

    SInspectBill target = new SInspectBill();
    target.setInspectTopic(source.getInspectTopic());
    target.setCategory(source.getCategory());
    target.setCategoryItem(source.getCategoryItem());
    target.setPlace(source.getPlace());
    target.setDealInfo(source.getDealInfo());
    target.setRemark(source.getRemark());
    target.setConfirmInfo(source.getConfirmInfo());
    target.setPermGroupId(source.getPermGroupId());
    target.setPermGroupTitle(source.getPermGroupTitle());

    target.setStore(source.getStore());
    target.setInspector(source.getInspector());
    target.setDutyPerson(source.getDutyPerson());
    target.setBuilding(source.getBuilding());
    target.setFloor(source.getFloor());

    target.setInspectTime(source.getInspectTime());
    target.setExpectTime(source.getExpectTime());
    target.setBeginTime(source.getBeginTime());
    target.setEndTime(source.getEndTime());

    target.setAfterPictures(
        ConverterUtil.convert(source.getAfterPictures(), SAttachment2Converter.getInstance()));
    target.setBeforePictures(
        ConverterUtil.convert(source.getBeforePictures(), SAttachment2Converter.getInstance()));
    
    target.setAbortMsg(source.getAbortMsg());

    return target;
  }

}
